package com.unieagle.exam.widget;

import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;

public class ScalingDrawable extends LayerDrawable{
	
	 float scaleX;
	 
	 float scaleY;

	ScalingDrawable(Drawable d, float scaleX, float scaleY)
	 {
		 super(new Drawable[] { d });
		 setScale(scaleX, scaleY);
	 }
	 ScalingDrawable(Drawable d, float scale)
	 {
		 this(d, scale, scale);
	 }
	 /** set the scales */
	 void setScale(float scaleX, float scaleY)
	 {
		 this.scaleX = scaleX;
		 this.scaleY = scaleY;
	 }
	 
	 void setScale(float scale)
	 {
		 setScale(scale, scale);
	 }
	 
	 @Override
	 public int getIntrinsicWidth()
	 {
		 return (int)(super.getIntrinsicWidth() * scaleX);
	 }
	 
	 @Override
	 public int getIntrinsicHeight()
	 {
		 return (int)(super.getIntrinsicHeight() * scaleY);
	 }
}
